<%@ page language="java" pageEncoding="UTF-8"%>

<jsp:include page="../inc/easyui.jsp"></jsp:include>
<script type="text/javascript" charset="utf-8">
	var userInfoForm;
	$(function() {
		userInfoForm = $('#userInfoForm').form({
			url : '${pageContext.request.contextPath}/userAction!edit.action',
			success : function(data) {
				var d = $.parseJSON(data);
				if (d && d.success) {
					$.messager.show({
						msg : d.msg,
						title : '提示'
					});
					userInfoForm.find('[name=password],[name=oldPassword]').val('');
				} else {
					$.messager.alert('提示', d.msg, 'error');
				}
			},
			onSubmit:function(){
				if($('#oldPassword').val() == "" || $('#password').val() == ""){
		     	 	$.messager.alert('提示', '密码不能为空', 'error');
		     	 	return false;
		     	 }else{
		     	 	return userInfoForm.form('validate');
		     	 }
	       }
		});

		$.ajax({
			url : '${pageContext.request.contextPath}/userAction!getTuser.action',
			data : {},
			cache : false,
			dataType : "json",
			type : "POST",
			success : function(r) {
				if (r.success) {
					var user = r.obj;
					$('#roleNames').html(user.tuserGroup.userGroupName);
					$('#resourcesNames').html(user.resourcesText);

					userInfoForm.form('load', user);
					userInfoForm.find('[name=password]').val('');
				} else {
					$.messager.alert('提示', r.msg, 'error');
				}
			}
		});
	});
	
	function submitForm(){
		userInfoForm.submit();
	}
</script>

<div class="easyui-layout" data-options="fit:true,border:false">
	<div region="center" border="false">
		<div class="easyui-panel" title="角色" border="false">
			<div id="roleNames" style="padding: 5px;"></div>
		</div>

		<div class="easyui-panel" title="修改密码">
			<div>
				<form id="userInfoForm" method="post">
					<table class="tableForm">
						<tr>
							<th>用户ID</th>
							<td><input name="id" readonly="readonly" /></td>
							<th>用户名</th>
							<td><input name="user" readonly="readonly" /></td>
							<th>创建时间</th>
							<td><input name="cjsj" readonly="readonly" style="width: 150px;" /></td>
						</tr>
						<tr>
							<th>姓名</th>
							<td><input name="name"  style="width: 150px;" /></td>
							<th>用户描述</th>
							<td><input name="userDescription"  style="width: 150px;" /></td>
						</tr>
						<tr>
							<th>原密码</th>
							<td><input name="oldPassword" id="oldPassword" type="password" style="width: 150px;" /></td>
							<th>新密码</th>
							<td><input name="password" id="password" type="password" style="width: 150px;" /></td>
						</tr>
						<tr>
							<td colspan="4" align="right"><a onclick="submitForm()" class="easyui-linkbutton" href="javascript:void(0);">修改密码</a>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>
</div>
